package com.pauldada.sakurabbs.controllers;

import com.pauldada.sakurabbs.entities.WebSiteInfo;
import com.pauldada.sakurabbs.services.WebSiteInfoService;
import com.pauldada.sakurabbs.util.PageUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

//帖子网站动态控制器
@Controller
@RequestMapping(value = "/webSiteInfo")
public class WebSiteInfoController {

	@Resource
	private WebSiteInfoService webSiteInfoService;

	//分页查询帖子网站动态信息
	@RequestMapping("/list/{id}")
	public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
		ModelAndView mav=new ModelAndView();
		List<WebSiteInfo> webSiteInfoList=webSiteInfoService.list(null, page, 20);
		Long total=webSiteInfoService.getCount(null);
		mav.addObject("webSiteInfoList", webSiteInfoList);
		mav.addObject("pageCode",PageUtil.genPagination("/webSiteInfo/list", total, page, 20));
		mav.addObject("title", "帖子网站动态信息列表");
		mav.addObject("mainPage", "webSiteInfo/list");
    	mav.addObject("mainPageKey", "#f");
    	mav.setViewName("index");
		return mav;
	}
}
